home *** CD-ROM | disk | FTP | other *** search
/ American History: Interactive Maps & User's Guide / American History: Interactive Maps & User's Guide.iso / pc / Perp.cxt / 00223.txt < prev    next >
Encoding:
Text File  |  2000-01-25  |  30.9 KB  |  862 lines

  1. --PRINT CODE
  2. --PROPERTY VARIABLES
  3. global gTextToBePresented
  4. --PrintContainer contains all the print properties and methods associated with the printing text and image components.
  5. --The properties and methods are defined below.
  6.  
  7. global printer
  8. property PrintList                               -- list of items set to print
  9. property PrintLayoutList                    -- property list of items containing item propertie set to print
  10. property PrintPageBreak                   -- boolean set true if text screen contains a page break, false otherwise
  11. property PrintCopyRight                    -- name of copyright field, contain copyright statement
  12. property PrintPageNumber                -- current print page number
  13. property PrintPageNumberBoolean  --  True if user has selected to print number in lower rigth side of document
  14. property PageCount                          -- total number of pages to print
  15.  
  16. on new me
  17.   set PrintList = []
  18.   set PrintLayoutList = []
  19.   set  PrintPageBreak = 36
  20.   set PrintPageNumber = 1
  21.   set PrintPageNumberBoolean = 1
  22.   set PageCount = 0
  23.   set PrintCopyRight = "Copyright"
  24.   return me  
  25. end
  26.  
  27. --TAKES: PrintContainer object
  28. --DOES: creates PrintLayoutList
  29. --RETURNS: PrintLayoutList
  30. on setPrintLayOut me
  31.   -- ΓÇó  initalize vars
  32.   set FieldName = ""
  33.   set CurrentPage = 1
  34.   set FieldName = "" 
  35.   set LineCounter = 0    
  36.   -- ΓÇó  get QuarkContianer object
  37.   set QuarkContainer  = getAt(the actorlist, 1)  
  38.   
  39.   -- ΓÇó  get list of field contained within  text container
  40.   set LayOut = the LayOut_list of   QuarkContainer  
  41.   set Odd = count(LayOut) mod 6
  42.   set Num0fPages = count(LayOut) / 6
  43.   -- ΓÇó  check if number of pages is odd and not less the two print documents
  44.   -- ΓÇó  single and multiple print documtents are treated differently ,ie. mulitple print pages requires two block checking
  45.   -- ΓÇó  check for  odd number of pages
  46.   if Odd = 3 and Num0fPages  <>  0 then
  47.     set Num0fPages = Num0fPages + 1
  48.   end if
  49.   -- ΓÇó  do if more than two pages
  50.   if Num0fPages  <>  0 then 
  51.     -- ΓÇó  repeat  to number of print pages
  52.     repeat With outercounter = 1 to  Num0fPages 
  53.       -- ΓÇó  reminder: Layout information is partition in  three pieces: offset information, start field and end field
  54.       -- ΓÇó  get start field of screen page
  55.       set Start = getAt(LayOut,((CurrentPage* 6)-6) + 2)      
  56.       
  57.       -- ΓÇó  if odd number of pages and current ly setting the last screen page then excute 
  58.       --else excute other statement
  59.       if Odd =3   and outercounter= Num0fPages  then
  60.         set Finish = getAt(LayOut,((CurrentPage  * 6)-6)+3)
  61.         set Middle = getAt(LayOut,((CurrentPage  * 6)-6)+3)
  62.       else
  63.         set Finish = getAt(LayOut,((CurrentPage  * 6)))
  64.         set Middle = getAt(LayOut,((CurrentPage  * 6)-1))
  65.       end if
  66.       
  67.       -- ΓÇó  parse through the fields of the screen page outercounter add info to PrintLayoutList
  68.       repeat with counter = Start  to Finish
  69.         set FieldName = getat(PrintList,counter)    
  70.         set LineCounte =  the number of lines in field FieldName     
  71.         set Justification = the alignment of member FieldName        
  72.         -- ΓÇó  if text block equal the second part ot text bock splt then check if need to recover lost info
  73.         
  74.         if counter  = Middle then
  75.           TestToAddSpace me,FieldName,CurrentPage,counter
  76.           add  PrintLayoutList [#FieldName:FieldName ,#Just:Justification, #Start:1,#End: LineCounte,#Page:CurrentPage]     
  77.           
  78.         else        
  79.           set Content = the text of    field FieldName
  80.           set LineOne =  line 1 of   Content
  81.           set LastLine = line LineCounte of   Content
  82.           
  83.           -- ΓÇó   Check for carriage return at beginng of text field and add correct response to PriontLayoutList
  84.           if (LineOne  = "" and  LastLine  = "") or  (LineOne  = " " and  LastLine  = "") or  (LineOne  = "" and  LastLine  = " ") or  (LineOne  = " " and  LastLine  = " ")  then    
  85.             set CurrentNum     = count (PrintLayoutList)
  86.             set PrevRec            = getAt(PrintLayoutList  , CurrentNum)               
  87.             set PrevRecName    = getProp(PrevRec   , #FieldName)
  88.             
  89.             if PrevRecName    <> "Level0" then
  90.               add  PrintLayoutList [#FieldName:"Level0" ,#Just:"left", #Start:1,#End: 1,#Page:CurrentPage ]
  91.             end if  
  92.             
  93.             add  PrintLayoutList [#FieldName:FieldName ,#Just:Justification, #Start:1,#End: LineCounte,#Page:CurrentPage]                 
  94.             
  95.             if  counter  <> Finish then 
  96.               add  PrintLayoutList [#FieldName:"Level0" ,#Just:"left", #Start:1,#End: 1,#Page:CurrentPage ]   
  97.             end if
  98.             
  99.           else  if LineOne  = "" or LineOne  = " " then
  100.             set CurrentNum = count (PrintLayoutList)
  101.             set PrevRec                        = getAt(PrintLayoutList  , CurrentNum)               
  102.             set PrevRecName                          = getProp(PrevRec   , #FieldName)
  103.             
  104.             if PrevRecName    <> "Level0" then
  105.               add  PrintLayoutList [#FieldName:"Level0" ,#Just:"left", #Start:1,#End: 1,#Page:CurrentPage ]
  106.             end if    
  107.             
  108.             add  PrintLayoutList [#FieldName:FieldName ,#Just:Justification, #Start:1,#End: LineCounte,#Page:CurrentPage]     
  109.             
  110.             --          else    if  LastLine   = "" or  LastLine = " "  then          
  111.             --            add  PrintLayoutList [#FieldName:FieldName ,#Just:Justification, #Start:1,#End: LineCounte,#Page:CurrentPage]   
  112.             --            
  113.             --            if  counter  <> Finish then 
  114.             --              add  PrintLayoutList [#FieldName:"Level0" ,#Just:"left", #Start:1,#End: 1,#Page:CurrentPage ]   
  115.             --            end if
  116.             --            
  117.           else       
  118.             add  PrintLayoutList [#FieldName:FieldName ,#Just:Justification, #Start:1,#End: LineCounte,#Page:CurrentPage]     
  119.           end if
  120.         end if
  121.         
  122.       end repeat
  123.       -- ΓÇó   Increment Current page
  124.       set CurrentPage =CurrentPage + 1
  125.     end repeat    
  126.   else
  127.     -- ΓÇó  do if more than one page
  128.     -- ΓÇó  get start and finish field of screen page
  129.     set Start = getAt(LayOut,2)
  130.     set Finish = getAt(LayOut,3)
  131.     
  132.     repeat with counter = Start  to Finish
  133.       -- ΓÇó  get properies of field
  134.       set FieldName = getat(PrintList,counter)    
  135.       set LineCounte =  the number of lines in field FieldName     
  136.       set Justification = the alignment of member FieldName        
  137.       -- ΓÇó  if text block equal the second part of text bock splt then check if need to recover lost info
  138.       
  139.       if counter  = Middle then
  140.         TestToAddSpace me,FieldName,CurrentPage,counter
  141.         
  142.         add  PrintLayoutList [#FieldName:FieldName ,#Just:Justification, #Start:1,#End: LineCounte,#Page:CurrentPage]     
  143.         
  144.       else        
  145.         set Content = the text of    field FieldName
  146.         set LineOne =  line 1 of   Content
  147.         set LastLine = line LineCounte of   Content
  148.         
  149.         -- ΓÇó   Check for carriage return at beginng of text field and add correct response to PriontLayoutList
  150.         if (LineOne  = "" and  LastLine  = "") or  (LineOne  = " " and  LastLine  = "") or  (LineOne  = "" and  LastLine  = " ") or  (LineOne  = " " and  LastLine  = " ")  then    
  151.           set CurrentNum     = count (PrintLayoutList)
  152.           set PrevRec            = getAt(PrintLayoutList  , CurrentNum)               
  153.           set PrevRecName    = getProp(PrevRec   , #FieldName)
  154.           
  155.           if PrevRecName    <> "Level0" then
  156.             add  PrintLayoutList [#FieldName:"Level0" ,#Just:"left", #Start:1,#End: 1,#Page:CurrentPage ]
  157.           end if  
  158.           
  159.           add  PrintLayoutList [#FieldName:FieldName ,#Just:Justification, #Start:1,#End: LineCounte,#Page:CurrentPage]                 
  160.           
  161.           if  counter  <> Finish then 
  162.             add  PrintLayoutList [#FieldName:"Level0" ,#Just:"left", #Start:1,#End: 1,#Page:CurrentPage ]   
  163.           end if
  164.           
  165.         else  if LineOne  = "" or LineOne  = " " then
  166.           set CurrentNum = count (PrintLayoutList)
  167.           set PrevRec                        = getAt(PrintLayoutList  , CurrentNum)               
  168.           set PrevRecName                          = getProp(PrevRec   , #FieldName)
  169.           
  170.           if PrevRecName    <> "Level0" then
  171.             add  PrintLayoutList [#FieldName:"Level0" ,#Just:"left", #Start:1,#End: 1,#Page:CurrentPage ]
  172.           end if    
  173.           
  174.           add  PrintLayoutList [#FieldName:FieldName ,#Just:Justification, #Start:1,#End: LineCounte,#Page:CurrentPage]     
  175.           
  176.           --        else    if  LastLine   = "" or  LastLine = " "  then          
  177.           --          add  PrintLayoutList [#FieldName:FieldName ,#Just:Justification, #Start:1,#End: LineCounte,#Page:CurrentPage]   
  178.           --          
  179.           --          if  counter  <> Finish then 
  180.           --            add  PrintLayoutList [#FieldName:"Level0" ,#Just:"left", #Start:1,#End: 1,#Page:CurrentPage ]   
  181.           --          end if
  182.           --          
  183.         else       
  184.           add  PrintLayoutList [#FieldName:FieldName ,#Just:Justification, #Start:1,#End: LineCounte,#Page:CurrentPage]     
  185.         end if
  186.       end if
  187.       
  188.     end repeat 
  189.   end if
  190.   put PrintLayoutList
  191. end
  192.  
  193. --TAKES: PrintContainer object 
  194. --DOES: calls print-o-matic methods to print General and Question Docs
  195. --RETURNS: n/a
  196. on setPrintDocument me
  197.   -- ΓÇó  initalize vars
  198.   set TextContainer     = getAt(the actorlist, 2)
  199.   set QPageCount           =  getTotalPage (TextContainer) 
  200.   set CurrentPrintPage = 1
  201.   set PageHeight =printer (mGetPageHeight)
  202.   set Count = Count( PrintLayoutList)
  203.   set LastPrintRec                        = getAt(PrintLayoutList  , Count)   
  204.   set MemberPrintRec                = getAt(PrintLayoutList  , 1)  
  205.   set MemberName                     = getProp(MemberPrintRec, #fieldName)
  206.   set PageCount                          = getProp(LastPrintRec, #Page)
  207.   
  208.   set MemberPrintRec                = getAt(PrintLayoutList  , 1)    
  209.   -- ΓÇó  set Question Switch
  210.   set QuestionSwitch = CheckForQuestions (me , gTextToBePresented)  
  211.   
  212.   if QuestionSwitch = true  then
  213.     set  PageCount   = QPageCount   
  214.   end if
  215.   
  216.   set NumberSwitch = false
  217.   set EndCounter =count(PrintLayoutList  )
  218.   -- ΓÇó  repeat to number of total number of items in PrintLayoutList
  219.   repeat With counter = 1 to EndCounter
  220.     set MemberPrintRec                = getAt(PrintLayoutList  , Counter)    
  221.     set MemberName                     = getProp(MemberPrintRec, #FieldName)
  222.     set MemberJustification          = getProp(MemberPrintRec, #Just)
  223.     set MemberStartLine               = getProp(MemberPrintRec, #Start)
  224.     set MemberEndLine                 = getProp(MemberPrintRec, #End)
  225.     set MemberPage                       = getProp(MemberPrintRec, #Page)
  226.     
  227.     -- ΓÇó  if Question Switch = true then check if the field contain questions
  228.     if  QuestionSwitch = true then 
  229.       Set NumberSwitch = FindNumberInField (me,MemberName     )
  230.     end if
  231.     
  232.     -- ΓÇó  print copyright statement at  bottom of print document
  233.     if   CurrentPrintPage  <> MemberPage then 
  234.       -- ΓÇó  call Copyright print method and  print number at lower right corner   
  235.       PrintCopyright me      
  236.       PrintPageNumber  me, CurrentPrintPage
  237.       set CurrentPrintPage = MemberPage     
  238.       -- ΓÇó  create and add new page to print-o-matic object
  239.       New_Page_doc me         
  240.       set VertOffset= 0      
  241.     else    if  counter =1 then      
  242.       set VertOffset= 0
  243.     else  
  244.       
  245.       -- ΓÇó  print text block are place vertically using print-o-matic's Insertion Point Method
  246.       set Insrtion_List = ""
  247.       set  Insrtion_List =  Printer( mGetInsertionPoint)     
  248.       set   the itemDelimiter to ","    
  249.       set VertOffset  = value(item 3 of Insrtion_List)            
  250.     end if  
  251.     
  252.     -- ΓÇó createnew Print Text block
  253.     Create_text_block  me, 0, VertOffset ,400,PageHeight ,false
  254.     Set_justification   me,MemberJustification 
  255.     set MemberNameAsList = []
  256.     do"set MemberNameAsList =  [MemberName]"  
  257.     -- ΓÇó Number switch is true for question docs   
  258.     if  NumberSwitch <> true then
  259.       
  260.       AppendStyledText (me,printer,MemberName , false)
  261.       
  262.     else     
  263.       -- ΓÇó add correct number of empty spaces after numbered questions
  264.       if QPageCount  = 1 then
  265.         setPrintQuestionDocument me,MemberName         
  266.       else       
  267.         if   counter <> EndCounter then           
  268.           setPrintQuestionDocument me,MemberName 
  269.         else      
  270.           -- ΓÇó  print number at lower right corner   
  271.           PrintPageNumber  me, CurrentPrintPage
  272.           set MemberTag = ["Empt"]
  273.           set VertOffset= 0      
  274.           Create_text_block  me, 0, VertOffset,400,PageHeight ,false
  275.           Set_justification   me,"left"
  276.           PrintStyledLine me, MemberTag, 1 ,1  
  277.           
  278.           New_Page_doc me 
  279.           setPrintQuestionDocument me,MemberName 
  280.           set CurrentPrintPage = 2
  281.           set  QPageCount  =  2       
  282.         end if
  283.       end if
  284.     end if
  285.   end Repeat
  286.   
  287.   
  288.   PrintPageNumber  me, CurrentPrintPage
  289.   -- ΓÇó  call Copyright print method
  290.   PrintCopyright me
  291. end if
  292. end
  293.  
  294.  
  295.  
  296. --TAKES: PrintContainer object, FieldName, Current Page
  297. --DOES: checks first line state for two blocks scenario
  298. --RETURNS: n/a
  299. on  TestToAddSpace me,pasFieldName,pasCurrentPage,pascounter
  300. set firstchar = char 1 of field pasFieldName
  301. set firstword = word 1 of field pasFieldName
  302. set charvalue   = charToNum(firstchar )
  303. set numchar  = the number of chars in  firstword 
  304. set wordvalue = 0
  305. set BoldSequence = false
  306. set PrevField = getAt(PrintList,pascounter)
  307. set NumlinePrev = the number of lines in  field PrevField
  308. set LastLineCnt = line NumlinePrev  of field pasFieldName
  309. --NOTES: "a" = ASCII 97
  310. --                "z" = ASCII "122"
  311. --                "A" = ASCII "65"
  312. --                "Z" = ASCII "90"
  313. --                "ΓÇó" = ASCII "165"
  314.  
  315. -- ΓÇó calculate the vlaue of th first word, defined as the sum of char ASCII values
  316. repeat with counter = 1 to  numchar
  317. set firstwordchar    = char counter of firstword 
  318. set wordvalue =   wordvalue +  charToNum(firstwordchar )
  319. end repeat
  320.  
  321. -- ΓÇó  if first char value greater  then 97 ("a")and  less 122 ("z")then lower case char ,thus  two block is a break in a paragraph 
  322. if  charvalue   >= 97 and   charvalue   <= 122 then
  323. --    put "Lower case" don't add spaces, it is a paagraph break
  324. return 
  325. else if  charvalue   >= 65 and   charvalue   <= 90 then
  326. --    put "Lower case" don't add spaces, it is a paagraph break
  327. return 
  328. else if  (charvalue   >= 48 and   charvalue   <= 57)  or charvalue = 165 then
  329. set CurrentNum = count (PrintLayoutList)
  330. set PrevRec                        = getAt(PrintLayoutList  , CurrentNum)               
  331. set PrevRecName                          = getProp(PrevRec   , #FieldName)
  332. if PrevRecName    <> "Level0" then
  333. add  PrintLayoutList [#FieldName:"Level0" ,#Just:"left", #Start:1,#End: 1,#Page:pasCurrentPage ]
  334. end if    
  335. return
  336. set numlines = the number of lines in field  pasFieldNAme
  337. -- ΓÇó to be a number or bullet sequence must be greater then 2 lines
  338. if numlines > 2 then 
  339. repeat  with counter = 2 to numlines
  340. set previous = line  counter -1 of field  pasFieldNAme
  341. set current = line  counter of field  pasFieldNAme
  342. set prevchar = char 1 of line counter -1 of field  pasFieldNAme
  343. set curchar = char 1 of line  counter of field  pasFieldNAme
  344. set prevalue = charToNum(prevchar)
  345. set curvalue   = charToNum(curchar )     
  346. -- ΓÇó checking for with or without empty spaces separating text blocks
  347. if ( prevalue   >= 48 and   prevalue   <= 57  or  prevalue = 165 ) and current   = "" and LastLineCnt <> "" then
  348. --          put "Level 2: Num or Bull with space"
  349.  
  350. set CurrentNum = count (PrintLayoutList)
  351. set PrevRec                        = getAt(PrintLayoutList  , CurrentNum)               
  352. set PrevRecName                          = getProp(PrevRec   , #FieldName)
  353. if PrevRecName    <> "Level0" then
  354. add  PrintLayoutList [#FieldName:"Level0" ,#Just:"left", #Start:1,#End: 1,#Page:pasCurrentPage ]
  355. end if    
  356. return
  357.  
  358. else if (prevalue  >= 48 and   prevalue   <= 57  or  prevalue= 165 )    and LastLineCnt <> ""  and ( curvalue   >= 48 and   curvalue   <= 57  or  curvalue = 165 )  then 
  359. --          put "Level 3: Num or Bull without  space"
  360. return
  361. end if       
  362. end repeat
  363. end if
  364. --
  365. -- ΓÇó if uppercase and bold  or bold then add space and not a number or bullet
  366. --else  if wordvalue < numchar* 97  and not( charvalue   >= 48 and   charvalue   <= 57  or charvalue = 165)  and LastLineCnt <> "" then 
  367. --set CurrentNum = count (PrintLayoutList)
  368. --set PrevRec                        = getAt(PrintLayoutList  , CurrentNum)               
  369. --set PrevRecName                          = getProp(PrevRec   , #FieldName)
  370. --if PrevRecName    <> "Level0" then
  371. --add  PrintLayoutList [#FieldName:"Level0" ,#Just:"left", #Start:1,#End: 1,#Page:pasCurrentPage ]
  372. --end if    
  373. --return
  374. --else  if the fontStyle of  word 1 of field pasFieldNAme = "bold"   and LastLineCnt <> "" then 
  375. --    put "Level 4: Bold Word "
  376. --set CurrentNum = count (PrintLayoutList)
  377. --set PrevRec                        = getAt(PrintLayoutList  , CurrentNum)               
  378. --set PrevRecName                          = getProp(PrevRec   , #FieldName)
  379. --if PrevRecName    <> "Level0" then
  380. --add  PrintLayoutList [#FieldName:"Level0" ,#Just:"left", #Start:1,#End: 1,#Page:pasCurrentPage ]
  381. --end if    
  382. --return
  383. --- ΓÇó if uppercase 
  384. --else  if  charvalue   >= 65 and   charvalue   <= 90  and LastLineCnt <> "" then
  385. --set CurrentNum = count (PrintLayoutList)
  386. --set PrevRec                        = getAt(PrintLayoutList  , CurrentNum)               
  387. --set PrevRecName                          = getProp(PrevRec   , #FieldName)
  388. --if PrevRecName    <> "Level0" then
  389. --add  PrintLayoutList [#FieldName:"Level0" ,#Just:"left", #Start:1,#End: 1,#Page:pasCurrentPage]
  390. --end if    
  391. --return
  392. end if 
  393. end 
  394.  
  395.  
  396. --TAKES: PrintContainer object, member name 
  397. --DOES: add correct number of empty lines after numbered questions .ie 3 or 4 lines
  398. --RETURNS: n/a
  399. on setPrintQuestionDocument me,pasMemberName
  400.  
  401. set PageHeight =printer (mGetPageHeight)
  402. set numlines = the number of lines in field pasMemberName
  403. repeat with counter = 1 to numlines
  404. set Insrtion_List = ""
  405. set  Insrtion_List =  Printer( mGetInsertionPoint)     
  406. set   the itemDelimiter to ","    
  407. set VertOffset = value(item 3 of Insrtion_List)            
  408. set curline =  line counter of  field pasMemberName
  409. set nextline =  line counter+ 1 of  field pasMemberName
  410.  
  411. if curline  = ""  and  nextline = ""   then
  412. set MemberName ="Level0"
  413. set Insrtion_List = ""
  414. set  Insrtion_List =  Printer( mGetInsertionPoint)     
  415. set   the itemDelimiter to ","    
  416. set VertOffset = value(item 3 of Insrtion_List)            
  417. Create_text_block  me, 0, VertOffset,400,PageHeight ,false
  418. Set_justification   me,"left"
  419. AppendStyledText (me,printer,MemberName , false)
  420. set Insrtion_List = ""
  421. set  Insrtion_List =  Printer( mGetInsertionPoint)     
  422. set   the itemDelimiter to ","    
  423. set VertOffset = value(item 3 of Insrtion_List)            
  424. Create_text_block  me, 0, VertOffset,400,PageHeight ,false
  425. Set_justification   me,"left"
  426. AppendStyledText (me,printer,MemberName , false)
  427. set Insrtion_List = ""
  428. set  Insrtion_List =  Printer( mGetInsertionPoint)     
  429. set   the itemDelimiter to ","    
  430. set VertOffset = value(item 3 of Insrtion_List)            
  431.  
  432. Create_text_block  me, 0, VertOffset,400,PageHeight ,false
  433. Set_justification   me,"left"
  434. AppendStyledText (me,printer,MemberName , false)
  435. set Insrtion_List = ""
  436. set  Insrtion_List =  Printer( mGetInsertionPoint)     
  437. set   the itemDelimiter to ","    
  438. set VertOffset = value(item 3 of Insrtion_List)            
  439.  
  440. Create_text_block  me, 0, VertOffset,400,PageHeight ,false
  441. Set_justification   me,"left"
  442. PrintStyledLine me,MemberName, 1 ,1
  443. set Insrtion_List = ""
  444. set  Insrtion_List =  Printer( mGetInsertionPoint)     
  445. set   the itemDelimiter to ","    
  446. set VertOffset = value(item 3 of Insrtion_List)            
  447. Create_text_block  me, 0, VertOffset,400,PageHeight ,false
  448. Set_justification   me,"left"
  449. AppendStyledText (me,printer,MemberName , false)
  450.  
  451. set Insrtion_List = ""
  452. set  Insrtion_List =  Printer( mGetInsertionPoint)     
  453. set   the itemDelimiter to ","    
  454. set VertOffset = value(item 3 of Insrtion_List)            
  455.  
  456. Create_text_block  me, 0, VertOffset,400,PageHeight ,false
  457. Set_justification   me,"left"
  458. set MemberNameAsList = []
  459. do"set MemberNameAsList =  [pasMemberName]"  
  460. AppendStyledText (me,printer,MemberName , false)
  461.  
  462. set Insrtion_List = ""
  463. set  Insrtion_List =  Printer( mGetInsertionPoint)     
  464. set   the itemDelimiter to ","    
  465. set VertOffset = value(item 3 of Insrtion_List)            
  466.  
  467. Create_text_block  me, 0, VertOffset,400,PageHeight ,false
  468. Set_justification   me,"left"
  469. set MemberNameAsList = []
  470. do"set MemberNameAsList =  [pasMemberName]"  
  471. AppendStyledText (me,printer,MemberName , false)
  472.  
  473. set Insrtion_List = ""
  474. set  Insrtion_List =  Printer( mGetInsertionPoint)     
  475. set   the itemDelimiter to ","    
  476. set VertOffset = value(item 3 of Insrtion_List)            
  477.  
  478. Create_text_block  me, 0, VertOffset,400,PageHeight ,false
  479. Set_justification   me,"left"
  480. set MemberNameAsList = []
  481. do"set MemberNameAsList =  [pasMemberName]"  
  482. AppendStyledText (me,printer,MemberName , false)
  483.  
  484. else
  485. set firstword =word 1 of line counter of  field pasMemberName
  486. set secondword = word 2 of line counter of  field pasMemberName
  487. if firstword = "1." or secondword  = "1." then
  488. set MemberName = "Level0"
  489. set Insrtion_List = ""
  490. set  Insrtion_List =  Printer( mGetInsertionPoint)     
  491. set   the itemDelimiter to ","    
  492. set VertOffset = value(item 3 of Insrtion_List)            
  493.  
  494. Create_text_block  me, 0, VertOffset,400,PageHeight ,false
  495. Set_justification   me,"left"
  496. AppendStyledText (me,printer,MemberName , false)
  497. end if
  498.  
  499. set Insrtion_List = ""
  500. set  Insrtion_List =  Printer( mGetInsertionPoint)     
  501. set   the itemDelimiter to ","    
  502. set VertOffset = value(item 3 of Insrtion_List)            
  503. Create_text_block  me, 0, VertOffset,400,PageHeight ,false
  504. Set_justification   me,"left"
  505. set MemberNameAsList = []
  506. do"set MemberNameAsList =  [pasMemberName]"  
  507. PrintStyledLine me,MemberNameAsList, counter ,counter
  508. end if
  509. end repeat
  510. end
  511.  
  512. --TAKES: PrintContainer object, member name 
  513. --DOES:  finds number in current line of field
  514. --RETURNS: true is  found number otherwise false
  515. on FindNumberInField me, pasFieldNAme
  516. set numlines = the number of lines in field pasFieldNAme
  517. repeat with counter = 1 to numlines
  518.  
  519. set firstchar = char 1 of line   counter of  field  pasFieldNAme
  520. set  charvalue = charToNum( firstchar)
  521. set NumSwitch = false
  522. if  charvalue   >= 48 and   charvalue   <= 57 then
  523. set NumSwitch = true
  524. exit repeat 
  525. else
  526. set NumSwitch = false
  527. end if
  528. end repeat
  529. return NumSwitch
  530. end
  531.  
  532. --TAKES: PrintContainer object  
  533. --DOES: Print-o-matic  append style txt method
  534. --RETURNS:n/a
  535. on AppendStyledText me, obj, theCast, autoAppend
  536. set Name = theCast
  537. set styleList = BuildStyleList( me,theCast)
  538.  
  539. repeat with cnt = 1 to count (styleList)
  540. set styleRun = getAt(styleList,cnt)
  541. obj(mSetTextFont,getAProp(styleRun,#font))
  542. obj(mSetTextSize,getAProp(styleRun,#size))
  543. obj(mSetTextStyle,getAProp(styleRun,#style))   
  544. set Colors = getAProp(styleRun,#color)
  545.  
  546. if Colors <> 0 then
  547. obj(mSetColor, 0, 0, 0)
  548. else
  549. obj(mSetColor, 255, 255, 255)
  550. end if
  551.  
  552. set charsAdded = obj(mAppendText,char getAProp(styleRun,#start) to ┬¼
  553. getAProp(styleRun,#end) of field theCast, autoAppend)
  554.  
  555.  
  556. if charsAdded = 0 then exit
  557. end repeat
  558. end
  559.  
  560. --TAKES: PrintContainer object  
  561. --DOES: Print-o-matic  style txt list method
  562. --RETURNS:n/a
  563. on BuildStyleList me, theCast
  564. set styleList = []
  565. set curFont = ""  
  566. set curSize = 0 
  567. set curStyle = ""  
  568. set curColor = 0 
  569. repeat with cnt = 1 to the number of chars in field  theCast
  570.  
  571. if the textFont of char cnt of cast theCast <> curFont ┬¼
  572. or the textSize of char cnt of cast theCast <> curSize ┬¼
  573. or the textStyle of char cnt of cast theCast <> curStyle then
  574. if count(styleList) then setAProp getAt(styleList,count(styleList)), #end, cnt-1
  575. set curFont =   the textFont of char cnt of cast theCast 
  576. set curSize = the textSize of char cnt of cast theCast
  577. set curStyle = the textStyle of char cnt of cast theCast
  578. set curColor  = the forecolor  of char cnt of cast theCast
  579. add styleList, [#font:curFont,#size:curSize,#style:curStyle,#start:cnt,#end:cnt,#color:curColor]   
  580. end if
  581. end repeat
  582. if count(styleList) then 
  583. setAProp getAt(styleList,count(styleList)), #end, the number of chars in field theCast
  584. end if
  585. return styleList
  586. end
  587.  
  588. --TAKES: PrintContainer object  
  589. --DOES: copyright print code
  590. --RETURNS:n/a
  591. on PrintCopyright me
  592. Create_text_block me,0, 650,391,printer(mGetPageHeight),false
  593. Set_justification me,  "left"
  594. AppendStyledText (me,printer,PrintCopyRight, false)  
  595. end
  596.  
  597. --TAKES: PrintContainer object  
  598. --DOES: number print code
  599. --RETURNS:n/a
  600. on PrintPageNumber me,PgNumber
  601.  
  602. Create_text_block me,378, 650 ,430,printer(mGetPageHeight),false
  603. Set_justification me, "center"
  604. set QuarkContainer = getAt(the actorlist, 1)  
  605. Set PageNumber =  "PageNumber"
  606. Set  the text of field PageNumber  to PgNumber&&"of" &&PageCount   
  607. AppendStyledText (me,printer,PageNumber, false)
  608. end 
  609.  
  610. --TAKES: PrintContainer object  
  611. --DOES: creates new print page
  612. --RETURNS:n/a
  613. on Create_page  me
  614. global printer
  615. printer (mNewPage)
  616. end
  617.  
  618.  
  619.  
  620. on initInitializePrintDoc me 
  621. Initialize_doc  me
  622. Create_doc   me
  623. Reset_doc  me
  624. end
  625.  
  626. on setPrintList me, pasPrintList
  627. set PrintList = pasPrintList
  628. end
  629.  
  630. on setPrint me,Print_type
  631. Print_doc  me,Print_type
  632. end
  633. on getPrintLayOut me
  634. return   PrintLayOut 
  635. end
  636.  
  637. on Print_doc me,state
  638. global printer
  639. --Case for different print state
  640. case state of 
  641. 1:
  642. --Print with dialog box
  643. if printer (mDoJobSetup) = true then
  644.   updateStage
  645.   printer (mPrint)
  646. end if
  647. --print without a dialog box
  648. 2: printer (mPrint)
  649. --print preveiw
  650. 3: printer (mPrintPreview)
  651. end case
  652. end 
  653.  
  654. on New_Page_doc  me
  655. printer (mNewPage)
  656. end
  657.  
  658. on SetLandscpape me,boolean
  659. printer (mSetLandscapeMode, boolean)
  660. end
  661.  
  662. --TAKES: PrintContainer object  
  663. --DOES: Print-o-matic  print bitmap method
  664. --RETURNS:n/a
  665. on SetmPicture me,PIcture,left,top, right, bottom
  666. --printer(mPicture,the picture of cast theCast,left,top,left+w,top+h)
  667. printer(mPicture,PIcture,left,top, right, bottom)
  668. end
  669.  
  670. --TAKES: PrintContainer object  
  671. --DOES: initialize xcmd or dll
  672. --RETURNS:n/a
  673. on Initialize_doc me
  674. global gXObjFile
  675. if the machineType = 256 then       
  676. put "pmatic.dll" into gXObjFile
  677. else
  678. put "pmatic.xobj" into gXObjFile
  679. end if
  680. end
  681.  
  682. --TAKES: PrintContainer object  
  683. --DOES: create instance of print-o-matic
  684. --RETURNS:n/a
  685. on Create_doc  me
  686. global printer, gXObjFile
  687.  
  688. if not objectP(printer) then
  689. openxlib gXObjFile 
  690. set  printer = PrintOMatic(mNew)
  691. end if
  692.  
  693. if not objectP(printer) then
  694. Alert "There is no currently selected printer. Printing features are disabled."
  695. else
  696. printer(mRegister,"PMAT130-245-01296")
  697. end if 
  698. end  
  699.  
  700. --TAKES: PrintContainer object  
  701. --DOES: Print-o-matic destructor sequence
  702. --RETURNS:n/a
  703. on DestroyPrint me
  704. Dispose_doc  me
  705. Close_doc  me
  706. end
  707.  
  708. --TAKES: PrintContainer object  
  709. --DOES: Print-o-matic  dispose method
  710. --RETURNS:n/a
  711. on  Dispose_doc me
  712. printer(mDispose)
  713. end
  714.  
  715. --TAKES: PrintContainer object  
  716. --DOES:close Print-o-matic  xcmd or dll
  717. --RETURNS:n/a
  718. on Close_doc me
  719. global gXObjFile
  720. closeXlib gXObjFile
  721. end
  722.  
  723. --TAKES: PrintContainer object  
  724. --DOES: Print-o-matic  reset method
  725. --RETURNS:n/a
  726. on Reset_doc me
  727. printer (mReset)
  728. end
  729.  
  730. --TAKES: PrintContainer object  
  731. --DOES: Print-o-matic set margins method
  732. --RETURNS:n/a
  733. on Set_margins me,left,top, right,bottom
  734. printer (mSetMargins,left,top, right, bottom)
  735. set  PageWidth = printer (mGetPageWidth) 
  736. set PageHeight =  printer (mGetPageHeight) 
  737. end
  738.  
  739. --TAKES: PrintContainer object  
  740. --DOES: Print-o-matic  create text block method
  741. --RETURNS:n/a
  742. on Create_text_block me,t,m,w,h, boolean
  743. printer (mTextBox,t,m,w,h,boolean) 
  744. end 
  745.  
  746. --TAKES: PrintContainer object  
  747. --DOES: Print-o-matic  jusification method
  748. --RETURNS:n/a
  749. on   Set_justification me, state
  750. printer (mSetTextJust, state)
  751. end
  752.  
  753. --TAKES: PrintContainer object, member name 
  754. --DOES: checks for print documentt type
  755. --RETURNS: true isf question doc otherwise false
  756. on CheckForQuestions me ,pasMemberName  
  757. set numchar = the number of chars in pasMemberName    
  758. repeat with counter = 1 to numchar
  759. set curchar = char counter of pasMemberName  
  760. set  Switch =  false    
  761. if curchar  = "Q" or curchar = "q" then
  762. set  Switch = true
  763. exit repeat     
  764. else 
  765. set  Switch =  false
  766. end if   
  767. end repeat  
  768. return Switch
  769. end
  770.  
  771. --TAKES: PrintContainer object  
  772. --DOES: Print-o-matic  append printstyle char method
  773. --RETURNS:n/a
  774. on PrintStyledLine me,castList, Start_Line, End_Line
  775. global printer, gXObjFile
  776. if not listP(castList) then exit
  777. repeat with cnt = 1 to count(castList)
  778. repeat with Counter = Start_Line to End_Line       
  779. AppendStyledLineText (me,printer,getAt(castList,cnt),Counter, true)
  780. Append_text RETURN, false
  781. end repeat
  782. end repeat  
  783. end if
  784. end
  785.  
  786. --TAKES: PrintContainer object  
  787. --DOES: modified Print-o-matic  Append Stlye start and end lines method
  788. --RETURNS:n/a
  789. on AppendStyledLineText me,obj, theCast, Start_Line,autoAppend
  790. if not objectP(obj) then exit
  791. if (not integerP(theCast)) and (not stringP(theCast)) then exit
  792. if the castType of cast theCast <> #text then exit
  793. if not(the number of chars in field theCast) then exit
  794. if not integerP(autoAppend) then set autoAppend = FALSE
  795. set styleList = BuildStyleLineList(me,theCast, Start_Line)
  796.  
  797. repeat with cnt = 1 to count (styleList)
  798. set styleRun = getAt(styleList,cnt)
  799. obj(mSetTextFont,getAProp(styleRun,#font))
  800. obj(mSetTextSize,getAProp(styleRun,#size))
  801. obj(mSetTextStyle,getAProp(styleRun,#style))   
  802. set Colors = getAProp(styleRun,#color)
  803.  
  804. if Colors <> 0 then
  805. obj(mSetColor, 0, 0, 0)
  806. else
  807. obj(mSetColor, 255, 255, 255)
  808. end if
  809. set charsAdded = obj(mAppendText,char getAProp(styleRun,#start) to ┬¼
  810. getAProp(styleRun,#end) of line  Start_Line of field theCast, autoAppend)
  811.  
  812. if   theCast = "line" then
  813. Append_text RETURN, false
  814. end if
  815.  
  816. if charsAdded = 0 then 
  817. exit
  818. end if
  819. end repeat
  820. end
  821.  
  822. --TAKES: PrintContainer object  
  823. --DOES: Print-o-matic  Build style list method
  824. --RETURNS:n/a
  825. on BuildStyleLineList me,theCast,Line_Count
  826.  
  827. if the castType of cast theCast <> #text then return []
  828.  
  829. set styleList = []
  830. set curFont = ""  
  831. set curSize = 0 
  832. set curStyle = ""  
  833. set curColor = 0 
  834. set NumOfChars = 0
  835. set NumOfChars = the number of chars in line Line_Count of field theCast
  836.  
  837. if  NumOfChars = 0 then 
  838. Append_text RETURN, false
  839. end if
  840.  
  841. repeat with cnt = 1 to NumOfChars
  842.  
  843. if the textFont of char cnt of line Line_Count of field theCast <> curFont ┬¼
  844. or the textSize of char cnt of line Line_Count of field theCast <> curSize ┬¼
  845. or the textStyle of char cnt of line Line_Count of field theCast<> curStyle then
  846.  
  847. if count(styleList) then setAProp getAt(styleList,count(styleList)), #end, cnt-1
  848. -- set our variables to the new current style
  849. put the textFont of char cnt of line Line_Count of field theCast into curFont
  850. put the textSize of char cnt of line Line_Count of field theCast into curSize
  851. put the textStyle of char cnt of line Line_Count of field theCast into curStyle
  852. set curColor  = the forecolor  of char cnt of line Line_Count of field theCast 
  853. add styleList, [#font:curFont,#size:curSize,#style:curStyle,#start:cnt,#end:cnt,#color:curColor]  
  854. end if
  855.  
  856. end repeat
  857. --close out the last style run in the list
  858. if count(styleList) then 
  859. setAProp getAt(styleList,count(styleList)), #end, the number of chars of line Line_Count of field theCast
  860. end if
  861. return styleList
  862. end